package top.heue.utils.log.printer

import top.heue.utils.log.LogLevel
import top.heue.utils.log.base.BasePrinter
import java.time.ZonedDateTime
import java.time.format.DateTimeFormatter

class ConsolePrinter : BasePrinter() {
    private val tsFormatter: DateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSXXX")
    private val nowString: String get() = ZonedDateTime.now().format(tsFormatter)
    override fun println(logLevel: LogLevel, tag: String, string: String) {
        val line = "[$nowString][${logLevel.name[0]}][$tag] $string"
        when (logLevel) {
            LogLevel.VERBOSE, LogLevel.DEBUG, LogLevel.INFO -> println(line)
            LogLevel.WARN, LogLevel.ERROR -> System.err.println(line)
        }
    }
}
